package io.wins.vertx.entity;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import io.wins.vertx.utils.UUIDUtils;
import org.apache.commons.lang3.StringUtils;

@DataObject(generateConverter = true)
public class Classification {
    private final String id;
    private String name;
    private String code;
    private boolean type;
    private int seq;
    private boolean active;

    public Classification(final JsonObject json) {
        ClassificationConverter.fromJson(json, this);
        this.id = StringUtils.isEmpty(json.getString("id")) ?
            UUIDUtils.genId() : json.getString("id");
    }

    public JsonObject toJson() {
        final JsonObject json = new JsonObject();
        ClassificationConverter.toJson(this, json);
        return json;
    }

    public String getId() {
        return this.id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(final String name) {
        this.name = name;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    public boolean isType() {
        return this.type;
    }

    public void setType(final boolean type) {
        this.type = type;
    }

    public int getSeq() {
        return this.seq;
    }

    public void setSeq(final int seq) {
        this.seq = seq;
    }

    public boolean isActive() {
        return this.active;
    }

    public void setActive(final boolean active) {
        this.active = active;
    }

}
